﻿using SimpleIpc;
using SimpleIpcCommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SimpleIpcClient
{
    class Program
    {
        static void Main(string[] args)
        {
            IRemoteChannel channel = RemoteChannelFactory.CreateIpcChannel("ipcClient");
            channel.RegisterChannel();

            var line = string.Empty;
            while (!(line = Console.ReadLine()).Equals("quit"))
            {
                var service = channel.GetObject<IService>("ipc://ipcServer/service");
                if (service != null)
                {
                    try
                    {
                        switch (line)
                        {
                            case "update":
                                service.UpateInfo("this.Main.Update");
                                break;
                            case "exit":
                                service.Exit();
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else
                {
                    Console.WriteLine("Service can't found!");
                }
            }

            Console.ReadLine();
        }
    }
}
